﻿#ifndef _SQLINDEX_H_H_
#define _SQLINDEX_H_H_

#include "udatabase/sqlrecord.h"

namespace FD{
	namespace Utility{
		namespace DB{
///<summary>
///提供生成和描述数据库索引的方法
///</summary>
class FD_DB_Export CSqlIndex : public FD::Utility::DB::CSqlRecord 
{
public:
	///<summary>
	///构造函数
	///</summary>
	CSqlIndex();
	///<summary>
	///构造函数
	///</summary>
	///<param name="cursorName">游标名</param>
	///<returns></returns>
	CSqlIndex(const FD::Kernel::FdUnicodeString &cursorName);
	///<summary>
	///构造函数
	///</summary>
	///<param name="cursorName">游标名</param>
	///<param name="name">索引名</param>
	///<returns></returns>
    CSqlIndex(const FD::Kernel::FdUnicodeString &cursorName, const FD::Kernel::FdUnicodeString &name);
	///<summary>
	///拷贝构造函数
	///</summary>
	///<param name="other">索引对象</param>
	///<returns></returns>
    CSqlIndex(const CSqlIndex &other);
	///<summary>
	///析构函数
	///</summary>
	///<param name=""></param>
	///<returns></returns>
    ~CSqlIndex();
	///<summary>
	///赋值操作符的重载
	///</summary>
	///<param name="other">索引对象</param>
	///<returns></returns>
    FD::Utility::DB::CSqlIndex &operator=(const FD::Utility::DB::CSqlIndex &other);
	///<summary>
	///设置当前索引对应的游标名
	///</summary>
	///<param name="cursorName">游标名</param>
	///<returns></returns>
   void setCursorName(const FD::Kernel::FdUnicodeString &cursorName);
	///<summary>
	///获取当前索引对应的游标名
	///</summary>
	///<param name=""></param>
	///<returns>当前索引对应的游标名</returns>
	inline const FD::Kernel::FdUnicodeString& cursorName() const {return cursor;};
	///<summary>
	///设置索引名
	///</summary>
	///<param name="name">索引名</param>
	///<returns></returns>
   void setName(const FD::Kernel::FdUnicodeString& name);
	///<summary>
	///获取当前索引对应的索引名
	///</summary>
	///<param name=""></param>
	///<returns>当前索引对应的索引名</returns>
	inline const FD::Kernel::FdUnicodeString& name() const {return nm;};
	///<summary>
	///有索引的字段链表中追加字段
	///</summary>
	///<param name="field">字段</param>
	///<returns></returns>
   void append(const FD::Utility::DB::CSqlField &field);
	///<summary>
	///有索引的字段链表中追加字段
	///</summary>
	///<param name="field">字段</param>
	///<param name="desc">是否为降序</param>
	///<returns></returns>
   void append(const FD::Utility::DB::CSqlField &field, bool desc);
	///<summary>
	///在索引i处的字段是否为降序排列
	///</summary>
	///<param name="i">索引号</param>
	///<returns>是降序返回true，否则返回false</returns>
    bool isDescending(INT32 i) const;
	///<summary>
	///设置在索引i处的字段是否为降序排列
	///</summary>
	///<param name="i">索引号</param>
	///<param name="desc">是否为降序</param>
	///<returns></returns>
   void setDescending(INT32 i, bool desc);

private:
	FD::Kernel::FdUnicodeString cursor;
    FD::Kernel::FdUnicodeString nm;
    std::list<bool> sorts;
};

} // namespace Database
} 
}

#endif //_SQLINDEX_H_H_

